﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Enums;
using XF.Common;
using XF.ExControls;
using System.Collections;

namespace BabySwim
{
    public partial class FrmCourseSelectionExceptionList : XFFormEx
    {
        XF.BLL.Course_SelectionException bll = new XF.BLL.Course_SelectionException();
        DateTimePicker dtpDateStart = new DateTimePicker();
        DateTimePicker dtpDateEnd = new DateTimePicker();
        public FrmCourseSelectionExceptionList()
        {
            InitializeComponent();
            dtpDateStart.Width = dtpDateEnd.Width = 120;
            ToolStripControlHost item = new ToolStripControlHost(dtpDateEnd);
            toolStrip1.Items.Insert(2, item);
            item = new ToolStripControlHost(dtpDateStart);
            toolStrip1.Items.Insert(1, item);
        }

        private void FrmCourseEvaluateSearch_Load(object sender, EventArgs e)
        {
            this.TextForeColor = ConfigSetting.TextForeColor;
            this.Icon = ConfigSetting.ProjectIcon;
            BindData();

        }

        private void BindData()
        {
            string strWhere = zDataConverter.AppendSQL(string.Empty, string.Format(" CourseDate Between '{0}' and '{1}'", dtpDateStart.Value.ToString(MessageText.FORMAT_DATE), dtpDateEnd.Value.AddDays(1).ToString(MessageText.FORMAT_DATE)));
            List<XF.Model.Course_SelectionException> models = bll.GetModelDetailList(strWhere);
            xfDataGridView1.Rows.Clear();
            foreach (XF.Model.Course_SelectionException model in models)
            {
                int count = xfDataGridView1.Rows.Count;
                xfDataGridView1.Rows.Add();
                xfDataGridView1.Rows[count].Cells[ColExceptionID.Name].Value = model.LeaveID;
                xfDataGridView1.Rows[count].Cells[ColCourseDate.Name].Value = model.CourseDate;
                xfDataGridView1.Rows[count].Cells[ColCourse.Name].Value = model.CourseID;
                xfDataGridView1.Rows[count].Cells[ColTeacher.Name].Value = model.TeacherID;
                xfDataGridView1.Rows[count].Cells[ColClassRoom.Name].Value = "教室" + MessageText.LIST_NUMBER_CHINESE[model.ClassRoomID];
                xfDataGridView1.Rows[count].Cells[ColStudentID.Name].Value = model.StudentID;
                xfDataGridView1.Rows[count].Cells[ColStudent.Name].Value = model.StudentCode + "-" + model.StudentName;
                xfDataGridView1.Rows[count].Cells[ColNickName.Name].Value = model.NickName;
                xfDataGridView1.Rows[count].Cells[ColFamilyID.Name].Value = model.FamilyID;
                xfDataGridView1.Rows[count].Cells[ColFamily.Name].Value = model.FamilyCode + "-" + model.FamilyName;
                xfDataGridView1.Rows[count].Cells[ColDescription.Name].Value = model.Description;
            }
        }

        private void tsBtnSearch_Click(object sender, EventArgs e)
        {
            BindData();
        }
    }
}
